(function () {
    // 移动端菜单打开关闭
    var toggle = document.getElementById("toggle-button"),
        menu = document.getElementById("mobile-menu"),
        icon = toggle.querySelector("i");
    toggle.addEventListener("click", function (e) {
        e.stopPropagation();
        menu.classList.toggle("open");
        if (icon.classList.contains("fa-bars")) {
            icon.classList.remove("fa-bars");
            icon.classList.add("fa-times");
        } else {
            icon.classList.remove("fa-times");
            icon.classList.add("fa-bars");
        }
    });
    // 移动端点击菜单外关闭菜单
    document.addEventListener("click", function (e) {
        if (menu.classList.contains("open")) {
            menu.classList.remove("open");
            icon.classList.remove("fa-times");
            icon.classList.add("fa-bars");
        }
    });
})(window);
